<template>
  <dv-border-box-4 class="tech-chart-card">
    <div class="tech-card-header">
      <span class="tech-title">简历创建趋势</span>
      <el-radio-group v-model="localTimeRange" size="small" class="tech-radio-group" @change="handleTimeRangeChange">
        <el-radio-button label="week">本周</el-radio-button>
        <el-radio-button label="month">本月</el-radio-button>
        <el-radio-button label="year">本年</el-radio-button>
      </el-radio-group>
    </div>
    <div class="chart-container">
      <dv-capsule-chart v-if="!loading" :config="resumeTrendConfig" class="dv-chart" />
      <dv-loading v-else>Loading...</dv-loading>
    </div>
  </dv-border-box-4>
</template>

<script>
import { ref, watch } from 'vue'

export default {
  name: 'ResumeTrendChart',
  props: {
    loading: {
      type: Boolean,
      default: false
    },
    resumeTrendConfig: {
      type: Object,
      required: true
    },
    timeRange: {
      type: String,
      default: 'week'
    }
  },
  emits: ['update:timeRange', 'change'],
  setup(props, { emit }) {
    const localTimeRange = ref(props.timeRange)
    
    watch(() => props.timeRange, (newValue) => {
      localTimeRange.value = newValue
    })
    
    const handleTimeRangeChange = (value) => {
      emit('update:timeRange', value)
      emit('change', value)
    }
    
    return {
      localTimeRange,
      handleTimeRangeChange
    }
  }
}
</script>

<style scoped>
.tech-chart-card {
  height: 350px;
  background-color: rgba(0, 20, 40, 0.7);
  padding: 15px;
}

.tech-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding: 0 10px;
}

.tech-title {
  font-size: 18px;
  font-weight: 600;
  color: #00c0ff;
  text-shadow: 0 0 10px rgba(0, 192, 255, 0.7);
}

.tech-radio-group :deep(.el-radio-button__inner) {
  background-color: rgba(0, 30, 60, 0.6);
  border-color: rgba(0, 192, 255, 0.5);
  color: #ffffff;
}

.tech-radio-group :deep(.el-radio-button__original-radio:checked + .el-radio-button__inner) {
  background-color: rgba(0, 192, 255, 0.3);
  border-color: rgba(0, 192, 255, 0.8);
  box-shadow: 0 0 10px rgba(0, 192, 255, 0.5);
  color: #00c0ff;
  text-shadow: 0 0 5px rgba(0, 192, 255, 0.7);
}

.chart-container {
  height: 280px;
  position: relative;
  padding: 10px;
}

.dv-chart {
  width: 100%;
  height: 100%;
}
</style>